<!--业务分析-排行版详情页-->
<template>
<div class="contain">
  <app-header></app-header>
  <dl class="m-header">
    <dt class="f-l relaImg">
      <img src="~images/icon/people-ico.png">
    </dt>
    <dd>
      <p><span>{{MedName}}</span></p>
      <!-- <p>李永辉 13011111111</p> -->
    </dd>
  </dl>
  <ul class="displayflex bus-rank-total">
    <li class="flex1">
      <p>总金额(元)</p>
      <em>{{Amount}}</em>
    </li>
    <li class="flex1">
      <p>销量</p>
      <em>{{qty}}</em>
    </li>
  </ul>
  <div class="bus-ana-tit">商品信息</div>
  <div class="bus-list-wrap">
    <div class="m-list-warp" v-for="item in CustomerAnalysis">
      <div class="m-list-pictxt">
        <div class="displayflex">
          <div class="pic w200"><img :src="item.PictContent | filterImgUrl"></div>
          <div class="m-list-txt flex1">
            <p>{{item.SupplierGoodsName}}</p>
            <p class="gray">生产厂商：{{item.Producer}}</p>
            <p class="gray">规格：{{item.SupplierGoodsSpec}}</p>
            <p class="gray">数量：<em class="red">{{item.SupplierPoQty}}{{item.SupplierUnit}}</em></p>
            <p class="gray">合计：<em class="red">￥{{item.Amount}}</em></p>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</template>

<script>
import appHeader from '@/components/core/header/app_header.vue';
export default {
  components: {
    appHeader
  },
  name: "crDetail",
  data() {
    return {
      CustomerAnalysis: [],
      Amount: 0,
      qty: 0,
      MedName: "",
      year: "",
      month: "",
      day: ""
    };
  },
  mounted() {
    this.$nextTick(function() {
      this.getData();
    });
  },
  methods: {
    getData: function() {
      var self = this;
      var MedGuid = self.$route.query.medGuid;
      var BuyerGuid = self.$route.query.medGuid;
      self.MedName = self.$route.query.MedName;
      var year = self.$route.query.year;
      var month = self.$route.query.month;
      var day = self.$route.query.day;
      var type = self.$route.query.type;
      var info = JSON.parse(localStorage.userinfo);
      if (type == "MedName") {
        BuyerGuid = "";
      } else if (type == "BuyerName") {
        MedGuid = "";
      }
      var query = {
        MedGuid: MedGuid,
        BuyerGUID: BuyerGuid,
        year: year,
        month: month,
        day: day,
        TenantGUID: info.TenantGUID,
        CorpGuid: info.CorpGuid
      };
      this.Ajax.post("CustomerDetailTopApi", query).then(function(resp) {
        if (resp.IsSuccess) {
          self.CustomerAnalysis = resp.Datas;
          self.CustomerAnalysis.forEach(function(element) {
            self.Amount += element.Amount;
            self.qty += element.SupplierPoQty;
          }, this);
        }
      });
    }
  }
};
</script>